﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JHT.EFMigrationTest.ClassLibrary1
{
    public class BooksMap : EntityTypeConfiguration<Books>
    {
        public BooksMap()
        {
            ToTable("Books");

            this.HasKey(p => new { p.BookNo, p.Edition });
            this.Property(p => p.BookNo).HasColumnName("BookNo").HasColumnType("varchar").IsRequired().HasMaxLength(30);
            this.Property(p => p.Edition).IsRequired().HasColumnType("int").HasColumnName("Edition");
            Property(p => p.BookName).IsRequired().HasColumnName("BookName").HasColumnType("varchar").HasMaxLength(50);
            Property(p => p.BookAuthor).IsRequired().HasColumnName("BookAuthor").HasColumnType("varchar").HasMaxLength(50).IsConcurrencyToken();
            Property(p => p.MyGUID).IsRequired().HasColumnName("MyGUID").HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity);
            Property(p => p.TimeStamp).IsRequired().IsRowVersion();// 所有更新操作都会带上该字段值

            MapToStoredProcedures();

        }
    }
}
